package com.adtech.core.helper;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Repository;

/**
 * Spring Bean工具，提供根据ID从容器中获取bean的功能
 * 
 * @since 2011-12-9
 * @author Dormin
 *
 * @Copyright (C) AD Tech Workshop All Right Reserved
 */
@Repository
public final class SpringBeanHelper implements ApplicationContextAware {
	
	private ApplicationContext context;
	
	/**
	 * get bean from spring context
	 * @param beanId spring bean ID
	 * @return 
	 */
	public Object getBean(String beanId) {
		return context.getBean(beanId);
	}
	
	public void setApplicationContext(ApplicationContext context) throws BeansException {
		this.context = context;
	}
}
